package cn.guat.smartpark.service.impl;

import cn.guat.smartpark.entity.FirePipelines;
import cn.guat.smartpark.mapper.FirePipelinesMapper;
import cn.guat.smartpark.service.FirePipelinesService;
import cn.guat.smartpark.utils.Fastjson2CoordinateParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FirePipelinesServiceImpl implements FirePipelinesService {
    /**
     * 依赖注入
     */
    @Autowired
    private FirePipelinesMapper firePipelinesMapper;

    @Override
    public FirePipelines getPipelinesById(String pipeId) {
        FirePipelines firePipelines=firePipelinesMapper.getPipelinesById(pipeId);
        if(firePipelines!=null){//判断空
            if(firePipelines.getStr()!=null){//判断坐标是否空
                //用工具类把字符串转map
                firePipelines.setCoordinatesData(Fastjson2CoordinateParser.parseCoordinate(firePipelines.getStr()));
                firePipelines.setStr(null);
                return firePipelines;
            }
            return firePipelines;
        }
        return null;
    }
}
